package com.bocaizp.operation.controller.user;

import com.bocaizp.common.result.Result;
import com.bocaizp.operation.mapper.DataAnalysisMapper;
import com.bocaizp.operation.service.DataAnalysisService;
import com.bocaizp.pojo.VO.AnalysisNameValueVO;
import com.bocaizp.pojo.VO.AnalysisStringVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Author : huang jie
 * Date : 2024/5/5 22:48
 **/
@RestController
@RequestMapping("/user")
@Slf4j
@CrossOrigin
public class UserAnalysisController {

	@Autowired
	private DataAnalysisService dataAnalysisService;

	@Autowired
	private DataAnalysisMapper dataAnalysisMapper;

	/**
	 * 全国岗位数分布
	 * @return
	 */
	@PostMapping("/analysis/country")
	public Result<List<AnalysisNameValueVO>> backCountry(){
		log.info("全国岗位数分布请求...");
		List<AnalysisNameValueVO> analysisNameValueVOS = dataAnalysisMapper.getCountry();
		return Result.success(analysisNameValueVOS);
	}

	/**
	 * 学历占比
	 * @return
	 */
	@PostMapping("/analysis/degrees")
	public Result<List<AnalysisNameValueVO>> backDegrees(){
		log.info("学历占比请求...");
		List<AnalysisNameValueVO> analysisNameValueVOS = dataAnalysisMapper.getDegrees();
		return Result.success(analysisNameValueVOS);
	}

	/**
	 * 获取行业平均薪资
	 * @return
	 */
	@PostMapping("/analysis/avgsalary")
	public Result<AnalysisStringVO> backAvgSalary(){
		log.info("平均薪资请求...");
		AnalysisStringVO analysisStringVO = dataAnalysisService.getAvgSalary();
		return Result.success(analysisStringVO);
	}

	/**
	 * 岗位总数变化
	 * @return
	 */
	@PostMapping("/analysis/jobnumber")
	public Result<AnalysisStringVO> backJobNumber(){
		log.info("岗位总数变化请求...");
		AnalysisStringVO analysisStringVO = dataAnalysisService.getJobNumber();
		return Result.success(analysisStringVO);
	}

	/**
	 * 行业热度
	 * @return
	 */
	@PostMapping("/analysis/hot")
	public Result<AnalysisStringVO> backIndustryHot(){
		log.info("行业热度请求...");
		AnalysisStringVO analysisStringVO = dataAnalysisService.getIndustryHot();
		return Result.success(analysisStringVO);
	}
}
